<?php
declare (strict_types = 1);

namespace app\middleware;

use Closure;
use think\facade\Session;
use think\Request;
use think\response\Redirect;

class Check
{
    /**
     * 处理请求
     *
     * @param Request $request
     * @param Closure       $next
     * @return Response|Redirect
     */
    public function handle($request, Closure $next)
    {

        if (!Session::get('id')){
            return redirect('toLogin');
        }

        $response = $next($request);

//         添加中间件执行代码
        return $response;
    }
}
